<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>AutoQ13</title>
    <link rel="stylesheet" href="/css/style.css">
    <link rel="stylesheet" href="/css/questionnaires.css">
</head>
<body>
    <!-- 导航栏 -->
    <div class="header">
        <div class="nav">
            <div class="nav-logo">问卷自动化系统</div>
        </div>
    </div>
    <div class="container">
    <!-- 问卷链接输入 -->
    <div class="card">
        <h2>问卷链接</h2>
        <div class="url-input-group">
            <input type="text" 
                   id="url" 
                   class="form-input" 
                   placeholder="请输入问卷星/腾讯问卷链接" 
                   autocomplete="off"
                   style="width: 100%;">
            <button class="btn btn-clear" id="clearBtn">清空</button>
            <button class="btn btn-primary" id="parseBtn">解析问卷</button>
        </div>
        <div class="parse-status" style="display: none;">
            <div class="loading-spinner"></div>
            <span>正在解析问卷内容...</span>
        </div>
    </div>

    <!-- 问卷内容展示 -->
    <div class="card" id="questionnaireContent" style="display: none;">
        <h2>问卷内容配置</h2>
        <div class="questionnaire-info">
            <h3 class="questionnaire-title">问卷标题</h3>
            <p class="questionnaire-desc">问卷描述</p>
        </div>

        <div class="questions-list" id="questions-container">
        </div>
    </div>

    <!-- 任务配置卡片 -->
    <div class="card" id="taskConfig" style="display: none;">
        <h2>任务配置</h2>
        <form id="questionnaireForm" class="form">
            <!-- 基础设置 -->
            <div class="form-group">
                <label class="form-label">填写次数</label>
                <input type="number" class="form-input" id="fillCount" min="1" max="1000" value="10" oninput="validateInput(this)" onkeydown="return event.keyCode !== 69" step="1">
                <small class="form-text text-muted">最大支持1000份问卷</small>
            </div>

            <div class="form-group">
                <label>间隔时间（秒）</label>
                <div class="interval-group">
                    <input type="number" class="form-input" id="intervalMin" min="1" value="2" style="width: 80px;" oninput="validateInput(this)">
                    <span style="margin: 0 10px;">至</span>
                    <input type="number" class="form-input" id="intervalMax" min="1" value="5" style="width: 80px;" oninput="validateInput(this)">
                    <span style="margin-left: 10px;">秒</span>
                </div>
                <small class="form-text text-muted">系统会在设定区间内随机选择等待时间</small>
            </div>

            <!-- 代理设置 -->
            <div class="form-group">
                <label class="form-label">
                    <input type="checkbox" id="useProxy"> 使用代理（使用后每次填写都会改变填写的IP地址）
                </label>
                <label for="proxySelect"></label><select class="form-input" id="proxySelect" disabled>
                    <option value="">使用系统代理</option>
                </select>
            </div>

            <!-- 信效度检验设置 -->
            <div class="form-group">
                <label class="form-label">
                    <input type="checkbox" id="enableReliability"> 启用信效度检验(并非所有问卷都需要这个检验，信度检验是针对量表题的，比如满意，不满意，这样有评分的，一般的问题不需要进行信度检验)
                </label>
                <div id="reliabilitySettings" style="display: none; margin-top: 10px; padding: 15px; background: #f8f9fa; border-radius: 8px; border: 1px solid #e9ecef;">
                    <!-- 使用任务配置中的填写次数，不再单独设置模拟填写份数 -->
                    
                    <div class="form-group">
                        <label class="form-label">参与计算的题目</label>
                        <div class="reliability-questions-container" id="reliabilityQuestionsContainer">
                            <!-- 题目选择将通过JavaScript动态添加 -->
                            <div class="empty-message">请先解析问卷内容</div>
                        </div>
                    </div>
                    
                    <div class="form-group">
                        <label class="form-label">信效度计算结果</label>
                        <div class="reliability-results" id="reliabilityResults">
                            <div class="reliability-result-item">
                                <span class="result-label">Cronbach's α系数:</span>
                                <span class="result-value" id="cronbachAlpha">-</span>
                                <span class="result-interpretation" id="cronbachAlphaInterpretation"></span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>


            <!-- 提交按钮 -->
            <button type="submit" class="btn btn-primary">开始任务</button>
        </form>
    </div>

    <!-- 在表单区域下方添加历史记录区域 -->
    <div class="history-section">
        <div class="history-header">
            <h3>最近解析记录</h3>
            <button class="clear-history-btn" onclick="clearUrlHistory()">
                <i class="fas fa-trash-alt"></i> 清空历史
            </button>
        </div>
        <div class="history-list" id="historyList">
            <!-- 历史记录将通过JavaScript动态添加 -->
        </div>
    </div>

</div>
<script src="/js/reliability.js"></script>
<script src="/js/questionnaires.js"></script>
</body>
</html>